package com.tg.service.suzakuEventBus.pojo;

import com.google.common.eventbus.Subscribe;
import com.tg.service.eventbus.EventHandler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;

import java.lang.reflect.ParameterizedType;

/**
 * Created by linzc on 2018/9/20.
 */
public abstract class BaseTask implements EventHandler<Tuple>, InitializingBean {

    @Override
    public void afterPropertiesSet() throws Exception {
//        this.taskName = getClazz().getSimpleName();
//        if(this.taskName.equals("SingleInvestTask")){
//            this.eventName = "invest";
//        }
//        else {
//            this.eventName = "login";
//        }
    }


    /**
     * 业务处理
     *
     * @param tuple tuple
     * @throws Exception Exception
     */
    public abstract void action(Tuple tuple) throws Exception;

    /**
     * 消息总线执行handler
     *
     * @param tuple 元组
     */
    @Override
    @Subscribe
    public void handle(Tuple tuple) {
        try {
            this.action(tuple);
        } catch (Exception ex) {

        }
    }
}
